package hms.HotelAdministrationModule;

import hms.generic.AbstractGlobalView;
import hms.inventory.ConfigInventoryFieldsControl;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;

/**
 * ConfigInventoryFieldsView is the GUI for configuring different item fields:
 * Color, Size, Item Category, and Vendor
 * 
 * @author Akilah McIntyre
 */
public class ConfigInventoryFieldsView extends AbstractGlobalView {

	// Controller
	private ConfigInventoryFieldsControl configInventoryFieldsControl;
	private JButton addColorButton;
	private JButton addItemCategoryButton;
	private JButton addCatlgItemButton;
	private JButton addSizeButton;
	private JButton changeColorButton;
	private JButton changeItemCategoryButton;
	private JButton changeCatlgItemButton;
	private JButton changeSizeButton;
	private JButton clearColorButton;
	private JButton clearItemCategoryButton;
	private JButton clearSizeButton;
	private JLabel colorLabel;
	private JLabel colorMsgLabel;
	private JScrollPane colorScrollPane;
	private JTextField colorTxtBox;
	private JPanel colorsPanel;
	private JList colors_jList;
	private JButton deleteColorButton;
	private JButton deleteItemCategoryButton;
	private JButton deleteCatlgItemButton;
	private JButton deleteSizeButton;
	private JPanel itemCatalogPanel;
	private JScrollPane itemCatalogScrollPane;
	private JList itemCatalog_jList;
	private JList categories_jList;
	private JPanel itemCategoriesPanel;
	private JScrollPane itemCategoriesScrollPane;
	private JLabel itemCategoryLabel;
	private JLabel itemCategoryMsgLabel;
	private JTextField itemCategoryTxtBox;
	private JPanel itemCatsVendorsTabPanel;
	private JLabel catlgItemLabel;
	private JLabel catlgItemMsgLabel;
	private JTextField catlgItemTxtBox;
	private JPanel catalogColorsSizesTabPanel;
	private JTabbedPane jTabbedPanel;
	private JLabel sizeLabel;
	private JLabel sizeMsgLabel;
	private JScrollPane sizeScrollPane;
	private JTextField sizeTxtBox;
	private JPanel sizesPanel;
	private JList sizes_jList;
	private JPanel configPanel;
	private Font defaultBoldFont;
	private Font defaultFont;
	private GridBagConstraints gbc_addCatlgItemButton;
	private GridBagConstraints gbc_changeCatlgItemButton;
	private GridBagConstraints gbc_deleteCatlgItemButton;

	private int selIndxColor = -1;
	private int selIndxSize = -1;
	private int selIndxCatlgItem = -1;
	private int selIndxItemCategory = -1;
	private int selIndxVendor = -1;
	private JPanel vendorsPanel;
	private JScrollPane vendorsScrollPane;
	private JTextField vendorTxtBox;
	private JButton addVendorButton;
	private JButton changeVendorButton;
	private JButton clearVendorButton;
	private JButton deleteVendorButton;
	private JLabel vendorMsgLabel;
	private JLabel vendorLabel;
	private JList vendors_jList;
	private JButton clearCatlgItemButton;
	private GridBagConstraints gridBagConstraints_1;
	private GridBagConstraints gridBagConstraints_2;
	private GridBagConstraints gridBagConstraints_3;
	private GridBagConstraints gridBagConstraints_4;
	private JPanel blankPanel;
	private static final String deletionWarning = "Deletion error.";
	private static final String deleteSelectWarning = "<html><p>Please select<br/> a value from the list.</p></html>";
	private static final String lengthWarning = "<html><p>Please enter a value with<br /> at least 2 and less than 129 characters</p></html>";
	private static final String selectWarning = "<html><p>Please select a value from the list.<br />Please enter a value with<br /> at least 2 and less than 129 characters.</p></html>";
	private static final String sizeLengthWarning = "<html><p>Please enter a value with<br /> at least 1 and less than 129 characters</p></html>";
	private static final String sizeSelectWarning = "<html><p>Please select a value from the list.<br />Please enter a value with<br /> at least 1 and less than 129 characters.</p></html>";
	private static final String updateWarning = "<html><p>Updating error.<br />Possible Duplicate Value.<br />Case insensitve.";
	private static final String duplicationWarning = "<html><p>Insertion error.<br />Possible Duplicate Value.<br />Case insensitve.</p></html>";

	public ConfigInventoryFieldsView() {
		initConfigItemSpecsControl();
		initComponents();
		super.update(configPanel);
		super.display(); // Display ConfigInventoryFieldsView
	}

	/**
	 * Create and initialize controller and entity objects
	 */
	private void initConfigItemSpecsControl() {
		configInventoryFieldsControl = new ConfigInventoryFieldsControl();
		configInventoryFieldsControl.init();
	}

	private void initComponents() {
		jTabbedPanel = new JTabbedPane();
		defaultBoldFont = new Font("Arial", 1, 11);
		defaultFont = new Font("Arial", 0, 11);
		configPanel = new JPanel();
		configPanel.setBorder(new TitledBorder(new EtchedBorder(
				EtchedBorder.LOWERED, null, null),
				"Configure Inventory Field Values", TitledBorder.LEADING,
				TitledBorder.TOP, null, null));
		GridBagLayout gbl_configPanel = new GridBagLayout();
		gbl_configPanel.columnWidths = new int[] { 450, 0 };
		gbl_configPanel.rowHeights = new int[] { 300, 0 };
		gbl_configPanel.columnWeights = new double[] { 0.0, Double.MIN_VALUE };
		gbl_configPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
		configPanel.setLayout(gbl_configPanel);

		initCatalogColorSizesTab();
		initItemCatsVendorsTab();

		GridBagConstraints gbc_jTabbedPane1 = new GridBagConstraints();
		gbc_jTabbedPane1.fill = GridBagConstraints.BOTH;
		gbc_jTabbedPane1.gridx = 0;
		gbc_jTabbedPane1.gridy = 0;
		configPanel.add(jTabbedPanel, gbc_jTabbedPane1);

		// configPanel.pack();
	}

	/**
	 * 
	 */
	private void initCatalogColorSizesTab() {
		catalogColorsSizesTabPanel = new JPanel();
		catalogColorsSizesTabPanel.setLayout(new GridBagLayout());

		initItemCatalogGUI();

		initColorGUI();

		initSizeGUI();

		jTabbedPanel.addTab("Configure Catalog, Colors, & Sizes", null,
				catalogColorsSizesTabPanel,
				"Configure Catalog, Colors, & Sizes");
	}

	/**
	 * 
	 */
	private void initItemCatsVendorsTab() {
		itemCatsVendorsTabPanel = new JPanel();
		GridBagLayout gbl_itemCatsVendorsTabPanel = new GridBagLayout();
		gbl_itemCatsVendorsTabPanel.rowWeights = new double[] { 1.0 };
		gbl_itemCatsVendorsTabPanel.columnWeights = new double[] { 1.0, 1.0,
				0.0, 0.0 };
		itemCatsVendorsTabPanel.setLayout(gbl_itemCatsVendorsTabPanel);

		initItemCategoryGUI();
		initVendorGUI();
		jTabbedPanel.addTab("Configure Categories & Vendors", null,
				itemCatsVendorsTabPanel, "Configure Categories & Vendors");

		blankPanel = new JPanel();
		GridBagConstraints gbc_blankPanel = new GridBagConstraints();
		gbc_blankPanel.insets = new Insets(0, 0, 0, 5);
		gbc_blankPanel.fill = GridBagConstraints.BOTH;
		gbc_blankPanel.gridx = 2;
		gbc_blankPanel.gridy = 0;
		itemCatsVendorsTabPanel.add(blankPanel, gbc_blankPanel);
	}

	private void initItemCatalogGUI() {
		GridBagConstraints gridBagConstraints;
		itemCatalogPanel = new JPanel();
		itemCatalogScrollPane = new JScrollPane();
		catlgItemLabel = new JLabel();

		itemCatalogPanel.setBorder(BorderFactory
				.createTitledBorder("Item Names"));
		itemCatalogPanel.setLayout(new GridBagLayout());
		initItemCatalogList();
		catlgItemTxtBox = new JTextField();

		catlgItemTxtBox.addActionListener(this);
		gridBagConstraints_4 = new GridBagConstraints();
		gridBagConstraints_4.gridx = 0;
		gridBagConstraints_4.gridy = 1;
		gridBagConstraints_4.gridwidth = 2;
		gridBagConstraints_4.ipadx = 115;
		gridBagConstraints_4.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints_4.insets = new Insets(6, 16, 5, 5);
		itemCatalogPanel.add(catlgItemTxtBox, gridBagConstraints_4);
		catlgItemLabel.setLabelFor(catlgItemTxtBox);
		addCatlgItemButton = new JButton();
		addCatlgItemButton.setActionCommand("addItemCatalogButton");
		addCatlgItemButton.setFont(defaultFont);
		addCatlgItemButton.setText("Add Item Name");
		addCatlgItemButton.addActionListener(this);
		gbc_addCatlgItemButton = new GridBagConstraints();
		gbc_addCatlgItemButton.gridx = 0;
		gbc_addCatlgItemButton.gridy = 2;
		gbc_addCatlgItemButton.gridwidth = 2;
		gbc_addCatlgItemButton.ipadx = 16;
		gbc_addCatlgItemButton.anchor = GridBagConstraints.NORTHWEST;
		gbc_addCatlgItemButton.insets = new Insets(11, 16, 5, 5);
		itemCatalogPanel.add(addCatlgItemButton, gbc_addCatlgItemButton);

		changeCatlgItemButton = new JButton();
		changeCatlgItemButton.setActionCommand("changeItemCatalogButton");

		changeCatlgItemButton.setFont(defaultFont);
		changeCatlgItemButton.setText("Change Item Name");
		changeCatlgItemButton.addActionListener(this);
		gbc_changeCatlgItemButton = new GridBagConstraints();
		gbc_changeCatlgItemButton.gridx = 0;
		gbc_changeCatlgItemButton.gridy = 3;
		gbc_changeCatlgItemButton.gridwidth = 2;
		gbc_changeCatlgItemButton.ipadx = 6;
		gbc_changeCatlgItemButton.anchor = GridBagConstraints.NORTHWEST;
		gbc_changeCatlgItemButton.insets = new Insets(6, 16, 5, 5);
		itemCatalogPanel.add(changeCatlgItemButton, gbc_changeCatlgItemButton);

		catlgItemLabel.setFont(defaultBoldFont);
		catlgItemLabel.setText("Item Catalog");
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(31, 16, 5, 5);
		itemCatalogPanel.add(catlgItemLabel, gridBagConstraints);

		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.ipadx = 18;
		gridBagConstraints.ipady = 75;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(11, 3, 100, 0);
		catalogColorsSizesTabPanel.add(itemCatalogPanel, gridBagConstraints);

		clearCatlgItemButton = new JButton();
		clearCatlgItemButton.setText("Clear Item Name");
		clearCatlgItemButton.setActionCommand("clearItemCatalogButton");
		clearCatlgItemButton.addActionListener(this);
		GridBagConstraints gbc_clearCatlgItemButton = new GridBagConstraints();
		gbc_clearCatlgItemButton.anchor = GridBagConstraints.WEST;
		gbc_clearCatlgItemButton.insets = new Insets(0, 10, 5, 0);
		gbc_clearCatlgItemButton.gridx = 2;
		gbc_clearCatlgItemButton.gridy = 1;
		itemCatalogPanel.add(clearCatlgItemButton, gbc_clearCatlgItemButton);
		deleteCatlgItemButton = new JButton();
		deleteCatlgItemButton.setActionCommand("deleteItemCatalogButton");

		deleteCatlgItemButton.setFont(defaultFont);
		deleteCatlgItemButton.setText("Delete Item Name");
		deleteCatlgItemButton.addActionListener(this);
		gbc_deleteCatlgItemButton = new GridBagConstraints();
		gbc_deleteCatlgItemButton.gridx = 0;
		gbc_deleteCatlgItemButton.gridy = 4;
		gbc_deleteCatlgItemButton.gridwidth = 2;
		gbc_deleteCatlgItemButton.anchor = GridBagConstraints.NORTHWEST;
		gbc_deleteCatlgItemButton.insets = new Insets(6, 16, 5, 5);
		itemCatalogPanel.add(deleteCatlgItemButton, gbc_deleteCatlgItemButton);
		catlgItemMsgLabel = new JLabel();
		// catlgItemMsgLabel.setLineWrap(true);
		// catlgItemMsgLabel.setEditable(false);

		catlgItemMsgLabel.setFont(defaultFont);
		catlgItemMsgLabel.setHorizontalAlignment(SwingConstants.LEFT);
		catlgItemMsgLabel.setVerticalAlignment(SwingConstants.TOP);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 5;
		gridBagConstraints.gridheight = 6;
		gridBagConstraints.ipadx = 35;
		gridBagConstraints.ipady = 32;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(18, 16, 18, 11);
		itemCatalogPanel.add(catlgItemMsgLabel, gridBagConstraints);
	}

	/**
	 * 
	 */
	private void initItemCatalogList() {
		itemCatalog_jList = new JList(configInventoryFieldsControl.catalog);
		GridBagConstraints gridBagConstraints;
		itemCatalog_jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		itemCatalog_jList
				.addListSelectionListener(createItemCatalogListSelectionListener());

		itemCatalogScrollPane.setViewportView(itemCatalog_jList);

		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 2;
		gridBagConstraints.gridy = 2;
		gridBagConstraints.gridheight = 11;
		gridBagConstraints.fill = GridBagConstraints.BOTH;
		gridBagConstraints.ipadx = 73;
		gridBagConstraints.ipady = 139;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.weightx = 1.0;
		gridBagConstraints.weighty = 1.0;
		gridBagConstraints.insets = new Insets(6, 10, 5, 15);
		itemCatalogPanel.add(itemCatalogScrollPane, gridBagConstraints);
	}

	/**
	 * @return ListSelectionListener for catalog_jList
	 */
	private ListSelectionListener createItemCatalogListSelectionListener() {
		return new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent e) {

				Object selectedCatlgItem = itemCatalog_jList.getSelectedValue();
				if (selectedCatlgItem != null) {
					catlgItemTxtBox.setText(selectedCatlgItem.toString());
					selIndxCatlgItem = itemCatalog_jList.getSelectedIndex();
					addCatlgItemButton.setEnabled(false);
				}
			}
		};
	}

	private void initColorGUI() {
		GridBagConstraints gridBagConstraints;
		colorsPanel = new JPanel();
		colorScrollPane = new JScrollPane();
		colorTxtBox = new JTextField();
		addColorButton = new JButton();
		changeColorButton = new JButton();
		changeColorButton.setActionCommand("changeColorButton");
		deleteColorButton = new JButton();
		deleteColorButton.setActionCommand("deleteColorButton");
		colorLabel = new JLabel();

		colorsPanel.setBorder(BorderFactory.createTitledBorder("Colors"));
		colorsPanel.setName("colors");
		colorsPanel.setLayout(new GridBagLayout());

		initColorsList();

		colorTxtBox.addActionListener(this);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 1;
		gridBagConstraints.gridwidth = 2;
		gridBagConstraints.ipadx = 91;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(6, 16, 5, 5);
		colorsPanel.add(colorTxtBox, gridBagConstraints);

		addColorButton.setFont(defaultFont);
		addColorButton.setText("Add Color");
		addColorButton.setActionCommand("addColorButton");
		addColorButton.addActionListener(this);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 2;
		gridBagConstraints.gridwidth = 2;
		gridBagConstraints.ipadx = 16;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(11, 16, 5, 5);
		colorsPanel.add(addColorButton, gridBagConstraints);

		changeColorButton.setFont(defaultFont);
		changeColorButton.setText("Change Color");
		changeColorButton.addActionListener(this);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 3;
		gridBagConstraints.gridwidth = 2;
		gridBagConstraints.ipadx = 6;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(6, 16, 5, 5);
		colorsPanel.add(changeColorButton, gridBagConstraints);

		deleteColorButton.setFont(defaultFont);
		deleteColorButton.setText("Delete Color");
		deleteColorButton.addActionListener(this);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 4;
		gridBagConstraints.gridwidth = 2;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(6, 16, 5, 5);
		colorsPanel.add(deleteColorButton, gridBagConstraints);
		clearColorButton = new JButton();
		GridBagConstraints gbc_clearColorButton = new GridBagConstraints();
		gbc_clearColorButton.anchor = GridBagConstraints.WEST;
		gbc_clearColorButton.insets = new Insets(0, 10, 5, 0);
		gbc_clearColorButton.gridx = 2;
		gbc_clearColorButton.gridy = 1;
		colorsPanel.add(clearColorButton, gbc_clearColorButton);
		clearColorButton.setActionCommand("clearColorButton");

		clearColorButton.setFont(defaultFont);
		clearColorButton.setText("Clear Color");
		clearColorButton.addActionListener(this);

		colorLabel.setFont(defaultBoldFont);
		colorLabel.setLabelFor(catlgItemTxtBox);
		colorLabel.setText("Color");
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(31, 16, 5, 5);
		colorsPanel.add(colorLabel, gridBagConstraints);

		gridBagConstraints_3 = new GridBagConstraints();
		gridBagConstraints_3.gridx = 1;
		gridBagConstraints_3.gridy = 0;
		gridBagConstraints_3.ipadx = 18;
		gridBagConstraints_3.ipady = 75;
		gridBagConstraints_3.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints_3.insets = new Insets(11, 3, 100, 0);
		catalogColorsSizesTabPanel.add(colorsPanel, gridBagConstraints_3);
		colorMsgLabel = new JLabel();
		// colorMsgLabel.setLineWrap(true);
		// colorMsgLabel.setEditable(false);

		colorMsgLabel.setFont(defaultFont);
		colorMsgLabel.setHorizontalAlignment(SwingConstants.LEFT);
		colorMsgLabel.setVerticalAlignment(SwingConstants.TOP);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 5;
		gridBagConstraints.gridheight = 6;
		gridBagConstraints.ipadx = 35;
		gridBagConstraints.ipady = 32;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(18, 16, 18, 11);
		colorsPanel.add(colorMsgLabel, gridBagConstraints);
		colorsPanel.getAccessibleContext().setAccessibleName("Colors");
	}

	/**
	 * 
	 */
	private void initColorsList() {
		GridBagConstraints gridBagConstraints;
		colors_jList = new JList(configInventoryFieldsControl.colors);
		colors_jList
				.addListSelectionListener(createColorsListSelectionListener());
		colors_jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		colorScrollPane.setViewportView(colors_jList);

		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 2;
		gridBagConstraints.gridy = 2;
		gridBagConstraints.gridheight = 10;
		gridBagConstraints.fill = GridBagConstraints.BOTH;
		gridBagConstraints.ipadx = 73;
		gridBagConstraints.ipady = 139;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.weightx = 1.0;
		gridBagConstraints.weighty = 1.0;
		gridBagConstraints.insets = new Insets(6, 10, 5, 15);
		colorsPanel.add(colorScrollPane, gridBagConstraints);
	}

	/**
	 * @return ListSelectionListener for colors_jList
	 */
	private ListSelectionListener createColorsListSelectionListener() {
		return new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent e) {
				Object selectedColor = colors_jList.getSelectedValue();
				if (selectedColor != null) {
					colorTxtBox.setText(selectedColor.toString());
					selIndxColor = colors_jList.getSelectedIndex();
					addColorButton.setEnabled(false);
				}
			}
		};
	}

	/**
	 * 
	 */
	private void initSizeGUI() {
		GridBagConstraints gridBagConstraints;
		sizesPanel = new JPanel();
		sizeScrollPane = new JScrollPane();
		changeSizeButton = new JButton();
		changeSizeButton.setActionCommand("changeSizeButton");
		deleteSizeButton = new JButton();
		deleteSizeButton.setActionCommand("deleteSizeButton");
		sizeLabel = new JLabel();

		sizesPanel.setBorder(BorderFactory.createTitledBorder("Sizes"));
		sizesPanel.setLayout(new GridBagLayout());

		initSizesList();

		sizeTxtBox = new JTextField();

		sizeTxtBox.addActionListener(this);
		gridBagConstraints_1 = new GridBagConstraints();
		gridBagConstraints_1.gridx = 0;
		gridBagConstraints_1.gridy = 1;
		gridBagConstraints_1.gridwidth = 3;
		gridBagConstraints_1.ipadx = 91;
		gridBagConstraints_1.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints_1.insets = new Insets(6, 16, 5, 0);
		sizesPanel.add(sizeTxtBox, gridBagConstraints_1);
		addSizeButton = new JButton();
		addSizeButton.setActionCommand("addSizeButton");

		addSizeButton.setFont(defaultFont);
		addSizeButton.setText("Add Size");
		addSizeButton.addActionListener(this);
		clearSizeButton = new JButton();
		clearSizeButton.setActionCommand("clearSizeButton");

		clearSizeButton.setFont(defaultFont);
		clearSizeButton.setText("Clear Size");
		clearSizeButton.addActionListener(this);
		GridBagConstraints gbc_clearSizeButton = new GridBagConstraints();
		gbc_clearSizeButton.insets = new Insets(0, 10, 5, 0);
		gbc_clearSizeButton.anchor = GridBagConstraints.NORTHWEST;
		gbc_clearSizeButton.gridx = 2;
		gbc_clearSizeButton.gridy = 1;
		sizesPanel.add(clearSizeButton, gbc_clearSizeButton);
		gridBagConstraints_2 = new GridBagConstraints();
		gridBagConstraints_2.gridx = 0;
		gridBagConstraints_2.gridy = 2;
		gridBagConstraints_2.gridwidth = 2;
		gridBagConstraints_2.ipadx = 16;
		gridBagConstraints_2.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints_2.insets = new Insets(11, 16, 5, 5);
		sizesPanel.add(addSizeButton, gridBagConstraints_2);
		changeSizeButton.setFont(defaultFont);
		changeSizeButton.setText("Change Size");
		changeSizeButton.addActionListener(this);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 3;
		gridBagConstraints.gridwidth = 2;
		gridBagConstraints.ipadx = 6;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(6, 16, 5, 5);
		sizesPanel.add(changeSizeButton, gridBagConstraints);

		deleteSizeButton.setFont(defaultFont);
		deleteSizeButton.setText("Delete Size");
		deleteSizeButton.addActionListener(this);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 4;
		gridBagConstraints.gridwidth = 2;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(6, 16, 5, 5);
		sizesPanel.add(deleteSizeButton, gridBagConstraints);

		sizeLabel.setFont(defaultBoldFont);
		sizeLabel.setLabelFor(catlgItemTxtBox);
		sizeLabel.setText("Size");
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(31, 16, 5, 5);
		sizesPanel.add(sizeLabel, gridBagConstraints);

		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 2;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.ipadx = 18;
		gridBagConstraints.ipady = 75;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(11, 3, 100, 0);
		catalogColorsSizesTabPanel.add(sizesPanel, gridBagConstraints);
		sizeMsgLabel = new JLabel();
		// sizeMsgLabel.setLineWrap(true);
		// sizeMsgLabel.setEditable(false);

		sizeMsgLabel.setFont(defaultFont);
		sizeMsgLabel.setHorizontalAlignment(SwingConstants.LEFT);
		sizeMsgLabel.setVerticalAlignment(SwingConstants.TOP);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 5;
		gridBagConstraints.gridheight = 6;
		gridBagConstraints.ipadx = 35;
		gridBagConstraints.ipady = 32;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(18, 16, 18, 11);
		sizesPanel.add(sizeMsgLabel, gridBagConstraints);
	}

	private void initSizesList() {
		GridBagConstraints gridBagConstraints;
		sizes_jList = new JList(configInventoryFieldsControl.sizes);
		sizes_jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		sizes_jList
				.addListSelectionListener(createSizesListSelectionListener());

		sizeScrollPane.setViewportView(sizes_jList);

		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 2;
		gridBagConstraints.gridy = 2;
		gridBagConstraints.gridheight = 11;
		gridBagConstraints.fill = GridBagConstraints.BOTH;
		gridBagConstraints.ipadx = 73;
		gridBagConstraints.ipady = 139;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.weightx = 1.0;
		gridBagConstraints.weighty = 1.0;
		gridBagConstraints.insets = new Insets(6, 10, 5, 15);
		sizesPanel.add(sizeScrollPane, gridBagConstraints);
	}

	/**
	 * @return ListSelectionListener for sizes_jList
	 */
	private ListSelectionListener createSizesListSelectionListener() {
		return new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent e) {
				Object selectedSize = sizes_jList.getSelectedValue();
				if (selectedSize != null) {
					sizeTxtBox.setText(selectedSize.toString());
					selIndxSize = sizes_jList.getSelectedIndex();
					addSizeButton.setEnabled(false);
				}
			}
		};
	}

	private void initItemCategoryGUI() {
		GridBagConstraints gridBagConstraints = new GridBagConstraints();

		itemCategoriesPanel = new JPanel();
		itemCategoryTxtBox = new JTextField();
		addItemCategoryButton = new JButton();
		addItemCategoryButton.setActionCommand("addItemCategoryButton");
		itemCategoryMsgLabel = new JLabel();
		// itemCategoryMsgLabel.setLineWrap(true);

		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.ipadx = 18;
		gridBagConstraints.ipady = 75;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(11, 3, 100, 5);
		itemCatsVendorsTabPanel.add(itemCategoriesPanel, gridBagConstraints);

		itemCategoriesPanel.setBorder(BorderFactory
				.createTitledBorder("Item Categories"));
		itemCategoriesPanel.setLayout(new GridBagLayout());

		itemCategoryTxtBox.addActionListener(this);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 1;
		gridBagConstraints.gridwidth = 2;
		gridBagConstraints.ipadx = 115;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(6, 16, 5, 5);
		itemCategoriesPanel.add(itemCategoryTxtBox, gridBagConstraints);

		addItemCategoryButton.setFont(defaultFont);
		addItemCategoryButton.setText("Add Category");
		addItemCategoryButton.addActionListener(this);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 2;
		gridBagConstraints.gridwidth = 2;
		gridBagConstraints.ipadx = 16;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(11, 16, 5, 5);
		itemCategoriesPanel.add(addItemCategoryButton, gridBagConstraints);

		changeItemCategoryButton = new JButton();
		changeItemCategoryButton.setActionCommand("changeItemCategoryButton");
		changeItemCategoryButton.setFont(defaultFont);
		changeItemCategoryButton.setText("Change Category");
		changeItemCategoryButton.addActionListener(this);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 3;
		gridBagConstraints.gridwidth = 2;
		gridBagConstraints.ipadx = 6;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(6, 16, 5, 5);
		itemCategoriesPanel.add(changeItemCategoryButton, gridBagConstraints);

		clearItemCategoryButton = new JButton();
		clearItemCategoryButton.setActionCommand("clearItemCategoryButton");
		clearItemCategoryButton.setFont(defaultFont);
		clearItemCategoryButton.setText("Clear Category");
		clearItemCategoryButton.addActionListener(this);
		GridBagConstraints gbc_clearItemCategoryButton = new GridBagConstraints();
		gbc_clearItemCategoryButton.gridy = 1;
		gbc_clearItemCategoryButton.gridx = 2;
		itemCategoriesPanel.add(clearItemCategoryButton,
				gbc_clearItemCategoryButton);

		deleteItemCategoryButton = new JButton();
		deleteItemCategoryButton.setActionCommand("deleteItemCategoryButton");
		deleteItemCategoryButton.setFont(defaultFont);
		deleteItemCategoryButton.setText("Delete Category");
		deleteItemCategoryButton.addActionListener(this);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 4;
		gridBagConstraints.gridwidth = 2;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(6, 16, 5, 5);
		itemCategoriesPanel.add(deleteItemCategoryButton, gridBagConstraints);
		itemCategoryLabel = new JLabel();
		itemCategoryMsgLabel.setFont(defaultFont);
		itemCategoryMsgLabel.setHorizontalAlignment(SwingConstants.LEFT);
		itemCategoryMsgLabel.setVerticalAlignment(SwingConstants.TOP);
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 5;
		gridBagConstraints.gridheight = 6;
		gridBagConstraints.ipadx = 35;
		gridBagConstraints.ipady = 32;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(18, 16, 18, 11);
		itemCategoriesPanel.add(itemCategoryMsgLabel, gridBagConstraints);

		itemCategoryLabel.setFont(defaultBoldFont);
		itemCategoryLabel.setLabelFor(catlgItemTxtBox);
		itemCategoryLabel.setText("Category");
		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.insets = new Insets(31, 16, 5, 5);
		itemCategoriesPanel.add(itemCategoryLabel, gridBagConstraints);

		initItemCategoriesList();
	}

	private void initItemCategoriesList() {
		itemCategoriesScrollPane = new JScrollPane();
		categories_jList = new JList(configInventoryFieldsControl.categories);
		categories_jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		categories_jList
				.addListSelectionListener(createItemCategoryListSelectionListener());
		itemCategoriesScrollPane.setViewportView(categories_jList);

		GridBagConstraints gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 2;
		gridBagConstraints.gridy = 2;
		gridBagConstraints.gridheight = 11;
		gridBagConstraints.fill = GridBagConstraints.BOTH;
		gridBagConstraints.ipadx = 73;
		gridBagConstraints.ipady = 139;
		gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
		gridBagConstraints.weightx = 1.0;
		gridBagConstraints.weighty = 1.0;
		gridBagConstraints.insets = new Insets(6, 10, 5, 15);
		itemCategoriesPanel.add(itemCategoriesScrollPane, gridBagConstraints);

	}

	/**
	 * @return ListSelectionListener for categories_jList
	 */
	private ListSelectionListener createItemCategoryListSelectionListener() {
		return new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent e) {
				Object selectedItemCategory = categories_jList
						.getSelectedValue();
				if (selectedItemCategory != null) {
					itemCategoryTxtBox.setText(selectedItemCategory.toString());
					selIndxItemCategory = categories_jList.getSelectedIndex();
					addItemCategoryButton.setEnabled(false);
				}
			}
		};
	}

	/**
	 * 
	 */
	private void initVendorGUI() {
		vendorsPanel = new JPanel();
		vendorsPanel.setName("vendor");

		vendorsPanel.setBorder(BorderFactory.createTitledBorder("Vendors"));
		GridBagConstraints gbc_vendorsPanel = new GridBagConstraints();
		gbc_vendorsPanel.ipady = 75;
		gbc_vendorsPanel.ipadx = 18;
		gbc_vendorsPanel.insets = new Insets(11, 3, 100, 0);
		gbc_vendorsPanel.anchor = GridBagConstraints.NORTHWEST;
		gbc_vendorsPanel.fill = GridBagConstraints.BOTH;
		gbc_vendorsPanel.gridx = 3;
		gbc_vendorsPanel.gridy = 0;
		itemCatsVendorsTabPanel.add(vendorsPanel, gbc_vendorsPanel);
		GridBagLayout gbl_vendorsPanel = new GridBagLayout();
		gbl_vendorsPanel.columnWidths = new int[] { 0, 0, 0, 0 };
		gbl_vendorsPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0 };
		gbl_vendorsPanel.columnWeights = new double[] { 0.0, 0.0, 0.0,
				Double.MIN_VALUE };
		gbl_vendorsPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0,
				0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
		vendorsPanel.setLayout(gbl_vendorsPanel);

		vendorLabel = new JLabel();
		vendorLabel.setText("Vendor");
		vendorLabel.setFont(new Font("Arial", Font.BOLD, 11));
		GridBagConstraints gbc_vendorLabel = new GridBagConstraints();
		gbc_vendorLabel.anchor = GridBagConstraints.NORTHWEST;
		gbc_vendorLabel.insets = new Insets(31, 16, 5, 5);
		gbc_vendorLabel.gridx = 0;
		gbc_vendorLabel.gridy = 0;
		vendorsPanel.add(vendorLabel, gbc_vendorLabel);

		vendorTxtBox = new JTextField();
		GridBagConstraints gbc_vendorTxtBox = new GridBagConstraints();
		gbc_vendorTxtBox.ipadx = 115;
		gbc_vendorTxtBox.anchor = GridBagConstraints.NORTHWEST;
		gbc_vendorTxtBox.gridwidth = 2;
		gbc_vendorTxtBox.insets = new Insets(6, 16, 5, 5);
		gbc_vendorTxtBox.gridx = 0;
		gbc_vendorTxtBox.gridy = 1;
		vendorsPanel.add(vendorTxtBox, gbc_vendorTxtBox);

		addVendorButton = new JButton();
		addVendorButton.setText("Add Vendor");
		addVendorButton.addActionListener(this);
		addVendorButton.setFont(new Font("Arial", Font.PLAIN, 11));
		addVendorButton.setActionCommand("addVendorButton");
		GridBagConstraints gbc_addVendorButton = new GridBagConstraints();
		gbc_addVendorButton.ipadx = 16;
		gbc_addVendorButton.anchor = GridBagConstraints.NORTHWEST;
		gbc_addVendorButton.gridwidth = 2;
		gbc_addVendorButton.insets = new Insets(11, 16, 5, 5);
		gbc_addVendorButton.gridx = 0;
		gbc_addVendorButton.gridy = 2;
		vendorsPanel.add(addVendorButton, gbc_addVendorButton);

		changeVendorButton = new JButton();
		changeVendorButton.setText("Change Vendor");
		changeVendorButton.setFont(new Font("Arial", Font.PLAIN, 11));
		changeVendorButton.setActionCommand("changeVendorButton");
		changeVendorButton.addActionListener(this);
		GridBagConstraints gbc_changeVendorButton = new GridBagConstraints();
		gbc_changeVendorButton.ipadx = 6;
		gbc_changeVendorButton.anchor = GridBagConstraints.NORTHWEST;
		gbc_changeVendorButton.gridwidth = 2;
		gbc_changeVendorButton.insets = new Insets(6, 16, 5, 5);
		gbc_changeVendorButton.gridx = 0;
		gbc_changeVendorButton.gridy = 3;
		vendorsPanel.add(changeVendorButton, gbc_changeVendorButton);

		clearVendorButton = new JButton();
		clearVendorButton.setText("Clear Vendor");
		clearVendorButton.setFont(new Font("Arial", Font.PLAIN, 11));
		clearVendorButton.setActionCommand("clearVendorButton");
		clearVendorButton.addActionListener(this);
		GridBagConstraints gbc_clearVendorButton = new GridBagConstraints();
		gbc_clearVendorButton.gridy = 1;
		gbc_clearVendorButton.gridx = 2;
		vendorsPanel.add(clearVendorButton, gbc_clearVendorButton);

		deleteVendorButton = new JButton();
		deleteVendorButton.setText("Delete Vendor");
		deleteVendorButton.setFont(new Font("Arial", Font.PLAIN, 11));
		deleteVendorButton.setActionCommand("deleteVendorButton");
		deleteVendorButton.addActionListener(this);
		GridBagConstraints gbc_deleteVendorButton = new GridBagConstraints();
		gbc_deleteVendorButton.anchor = GridBagConstraints.NORTHWEST;
		gbc_deleteVendorButton.gridwidth = 2;
		gbc_deleteVendorButton.insets = new Insets(6, 16, 5, 5);
		gbc_deleteVendorButton.gridx = 0;
		gbc_deleteVendorButton.gridy = 4;
		vendorsPanel.add(deleteVendorButton, gbc_deleteVendorButton);

		vendorMsgLabel = new JLabel();
		// vendorMsgLabel.setLineWrap(true);
		// vendorMsgLabel.setEditable(false);
		vendorMsgLabel.setVerticalAlignment(SwingConstants.TOP);
		vendorMsgLabel.setHorizontalAlignment(SwingConstants.LEFT);
		vendorMsgLabel.setFont(new Font("Arial", Font.PLAIN, 11));
		GridBagConstraints gbc_vendorMsgLabel = new GridBagConstraints();
		gbc_vendorMsgLabel.ipady = 32;
		gbc_vendorMsgLabel.ipadx = 35;
		gbc_vendorMsgLabel.anchor = GridBagConstraints.NORTHWEST;
		gbc_vendorMsgLabel.gridheight = 6;
		gbc_vendorMsgLabel.insets = new Insets(18, 16, 18, 11);
		gbc_vendorMsgLabel.gridx = 0;
		gbc_vendorMsgLabel.gridy = 5;
		vendorsPanel.add(vendorMsgLabel, gbc_vendorMsgLabel);
		initVendorsList();
	}

	private void initVendorsList() {
		vendorsScrollPane = new JScrollPane();
		vendors_jList = new JList(configInventoryFieldsControl.vendors);
		vendors_jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		vendors_jList
				.addListSelectionListener(createVendorsListSelectionListener());
		vendorsScrollPane.setViewportView(vendors_jList);

		GridBagConstraints gbc_vendorsScrollPane = new GridBagConstraints();
		gbc_vendorsScrollPane.weighty = 1.0;
		gbc_vendorsScrollPane.weightx = 1.0;
		gbc_vendorsScrollPane.ipady = 139;
		gbc_vendorsScrollPane.ipadx = 73;
		gbc_vendorsScrollPane.fill = GridBagConstraints.BOTH;
		gbc_vendorsScrollPane.anchor = GridBagConstraints.NORTHWEST;
		gbc_vendorsScrollPane.gridheight = 11;
		gbc_vendorsScrollPane.insets = new Insets(6, 10, 5, 15);
		gbc_vendorsScrollPane.gridx = 2;
		gbc_vendorsScrollPane.gridy = 2;
		vendorsPanel.add(vendorsScrollPane, gbc_vendorsScrollPane);
	}

	/**
	 * @return ListSelectionListener for vendors_jList
	 */
	private ListSelectionListener createVendorsListSelectionListener() {
		return new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent e) {
				Object selectedVendor = vendors_jList.getSelectedValue();
				if (selectedVendor != null) {
					vendorTxtBox.setText(selectedVendor.toString());
					selIndxVendor = vendors_jList.getSelectedIndex();
					addVendorButton.setEnabled(false);
				}
			}
		};
	}

	/**
	 * 
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getActionCommand().equalsIgnoreCase("addItemCatalogButton")) {
			addItemCatalog();
		}
		if (e.getActionCommand().equalsIgnoreCase("changeItemCatalogButton")) {
			changeItemCatalog();
			itemCatalog_jList.clearSelection();
		}
		if (e.getActionCommand().equalsIgnoreCase("deleteItemCatalogButton")) {
			deleteItemCatalog();
		}
		if (e.getActionCommand().equalsIgnoreCase("clearItemCatalogButton")) {
			clearItemCatalog();
		}
		if (e.getActionCommand().equalsIgnoreCase("addColorButton")) {
			addColor();
		}
		if (e.getActionCommand().equalsIgnoreCase("changeColorButton")) {
			changeColor();
			colors_jList.clearSelection();
		}
		if (e.getActionCommand().equalsIgnoreCase("deleteColorButton")) {
			deleteColor();
		}
		if (e.getActionCommand().equalsIgnoreCase("clearColorButton")) {
			clearColor();
		}
		if (e.getActionCommand().equalsIgnoreCase("addSizeButton")) {
			addSize();
		}
		if (e.getActionCommand().equalsIgnoreCase("changeSizeButton")) {
			changeSize();
			sizes_jList.clearSelection();
		}
		if (e.getActionCommand().equalsIgnoreCase("deleteSizeButton")) {
			deleteSize();
		}
		if (e.getActionCommand().equalsIgnoreCase("clearSizeButton")) {
			clearSize();
		}
		if (e.getActionCommand().equalsIgnoreCase("addItemCategoryButton")) {
			addItemCategory();
		}
		if (e.getActionCommand().equalsIgnoreCase("changeItemCategoryButton")) {
			changeItemCategory();
			categories_jList.clearSelection();
		}
		if (e.getActionCommand().equalsIgnoreCase("deleteItemCategoryButton")) {
			deleteItemCategory();
		}
		if (e.getActionCommand().equalsIgnoreCase("clearItemCategoryButton")) {
			clearItemCategory();
		}
		if (e.getActionCommand().equalsIgnoreCase("addVendorButton")) {
			addVendor();
		}
		if (e.getActionCommand().equalsIgnoreCase("changeVendorButton")) {
			changeVendor();
			vendors_jList.clearSelection();
		}
		if (e.getActionCommand().equalsIgnoreCase("deleteVendorButton")) {
			deleteVendor();
		}
		if (e.getActionCommand().equalsIgnoreCase("clearVendorButton")) {
			clearVendor();
		}
	}

	private void addItemCatalog() {
		String new_catlgItem_name = catlgItemTxtBox.getText().toUpperCase();

		if (new_catlgItem_name != null && new_catlgItem_name.length() > 1
				&& new_catlgItem_name.length() < 129) {
			boolean flag = configInventoryFieldsControl
					.insertItemCatalog(new_catlgItem_name);
			if (flag) {
				catlgItemTxtBox.setText("");
				catlgItemMsgLabel.setText("");
				catlgItemTxtBox.setForeground(Color.BLACK);
			} else {
				// Display Duplicate Value Warning
				catlgItemMsgLabel.setForeground(Color.RED);
				catlgItemMsgLabel.setText(duplicationWarning);
				catlgItemTxtBox.setText("");
			}
		} else {
			// Display Warning
			catlgItemMsgLabel.setForeground(Color.RED);
			catlgItemMsgLabel.setText(lengthWarning);
			catlgItemTxtBox.setText("");
		}
	}

	/**
	 * Adds an inventory color to database
	 */
	private void addColor() {
		String new_color_name = colorTxtBox.getText().toUpperCase();

		if (new_color_name != null && new_color_name.length() > 1
				&& new_color_name.length() < 129) {
			boolean flag = configInventoryFieldsControl
					.insertColor(new_color_name);
			if (flag) {
				colorTxtBox.setText("");
				colorMsgLabel.setText("");
				colorTxtBox.setForeground(Color.BLACK);
			} else {
				// Display Duplicate Value Warning
				colorMsgLabel.setForeground(Color.RED);
				colorMsgLabel.setText(duplicationWarning);
				colorTxtBox.setText("");
			}
		} else {
			// Display Warning
			colorMsgLabel.setForeground(Color.RED);
			colorMsgLabel.setText(lengthWarning);
			colorTxtBox.setText("");
		}
	}

	/**
	 * Adds an size to database
	 */
	private void addSize() {
		String new_size_name = sizeTxtBox.getText().toUpperCase();

		if (new_size_name != null && new_size_name.length() > 0
				&& new_size_name.length() < 129) {
			boolean flag = configInventoryFieldsControl
					.insertSize(new_size_name);
			if (flag) {
				sizeTxtBox.setText("");
				sizeMsgLabel.setText("");
				sizeMsgLabel.setForeground(Color.BLACK);
			} else {
				// Display Duplicate Value Warning
				sizeMsgLabel.setForeground(Color.RED);
				sizeMsgLabel.setText(duplicationWarning);
				sizeTxtBox.setText("");
			}
		} else {
			// Display Warning
			sizeMsgLabel.setForeground(Color.RED);
			sizeMsgLabel.setText(sizeLengthWarning);
			sizeTxtBox.setText("");
		}
	}

	private void addItemCategory() {
		String new_itemCategory_name = itemCategoryTxtBox.getText()
				.toUpperCase();

		if (new_itemCategory_name != null && new_itemCategory_name.length() > 1
				&& new_itemCategory_name.length() < 129) {
			boolean flag = configInventoryFieldsControl
					.insertItemCategory(new_itemCategory_name);
			if (flag) {
				itemCategoryTxtBox.setText("");
				itemCategoryMsgLabel.setText("");
				itemCategoryTxtBox.setForeground(Color.BLACK);
			} else {
				// Display Duplicate Value Warning
				itemCategoryMsgLabel.setForeground(Color.RED);
				itemCategoryMsgLabel.setText(duplicationWarning);
				itemCategoryTxtBox.setText("");
			}
		} else {
			// Display Warning
			itemCategoryMsgLabel.setForeground(Color.RED);
			itemCategoryMsgLabel.setText(lengthWarning);
			itemCategoryTxtBox.setText("");
		}

	}

	/**
	 * Adds an vendor to database
	 */
	private void addVendor() {
		String new_vendor_name = vendorTxtBox.getText().toUpperCase();

		if (new_vendor_name != null && new_vendor_name.length() > 0
				&& new_vendor_name.length() < 129) {
			boolean flag = configInventoryFieldsControl
					.insertVendor(new_vendor_name);
			if (flag) {
				vendorTxtBox.setText("");
				vendorMsgLabel.setText("");
				vendorMsgLabel.setForeground(Color.BLACK);
			} else {
				// Display Duplicate Value Warning
				vendorMsgLabel.setForeground(Color.RED);
				vendorMsgLabel.setText(duplicationWarning);
				vendorTxtBox.setText("");
			}
		} else {
			// Display Warning
			vendorMsgLabel.setForeground(Color.RED);
			vendorMsgLabel.setText(lengthWarning);
			vendorTxtBox.setText("");
		}
	}

	private void changeItemCatalog() {
		String catlgItem_name = catlgItemTxtBox.getText().toUpperCase();

		if (catlgItem_name != null && catlgItem_name.length() > 1
				&& catlgItem_name.length() < 129) {
			boolean flag = configInventoryFieldsControl.updateItemCatalog(
					catlgItem_name, selIndxCatlgItem);
			if (flag) {
				catlgItemTxtBox.setText("");
				catlgItemMsgLabel.setText("");
				catlgItemMsgLabel.setForeground(Color.BLACK);
				addCatlgItemButton.setEnabled(true);
				selIndxCatlgItem = -1;
				categories_jList.repaint();
			} else {
				// Display Duplicate Value Warning
				catlgItemMsgLabel.setForeground(Color.RED);
				catlgItemMsgLabel.setText(updateWarning);
				catlgItemTxtBox.setText("");
			}
		} else {
			// Display Warning
			catlgItemMsgLabel.setForeground(Color.RED);
			catlgItemMsgLabel.setText(selectWarning);
			catlgItemTxtBox.setText("");
		}
	}

	private void changeItemCategory() {
		String itemCategory_name = itemCategoryTxtBox.getText().toUpperCase();

		if (itemCategory_name != null && itemCategory_name.length() > 1
				&& itemCategory_name.length() < 129) {
			boolean flag = configInventoryFieldsControl.updateItemCategory(
					itemCategory_name, selIndxItemCategory);
			if (flag) {
				itemCategoryTxtBox.setText("");
				itemCategoryMsgLabel.setText("");
				itemCategoryMsgLabel.setForeground(Color.BLACK);
				addItemCategoryButton.setEnabled(true);
				selIndxItemCategory = -1;
				categories_jList.repaint();
			} else {
				// Display Duplicate Value Warning
				itemCategoryMsgLabel.setForeground(Color.RED);
				itemCategoryMsgLabel.setText(updateWarning);
				itemCategoryTxtBox.setText("");
			}
		} else {
			// Display Warning
			itemCategoryMsgLabel.setForeground(Color.RED);
			itemCategoryMsgLabel.setText(selectWarning);
			itemCategoryTxtBox.setText("");
		}
	}

	private void changeColor() {
		String color_name = colorTxtBox.getText().toUpperCase();

		if (color_name != null && color_name.length() > 1
				&& color_name.length() < 129) {
			boolean flag = configInventoryFieldsControl.updateColor(color_name,
					selIndxColor);
			if (flag) {
				colorTxtBox.setText("");
				colorMsgLabel.setText("");
				colorMsgLabel.setForeground(Color.BLACK);
				addColorButton.setEnabled(true);
				selIndxColor = -1;
				colors_jList.repaint();
			} else {
				// Display Duplicate Value Warning
				colorMsgLabel.setForeground(Color.RED);
				colorMsgLabel.setText(updateWarning);
				colorTxtBox.setText("");
			}
		} else {
			// Display Warning
			colorMsgLabel.setForeground(Color.RED);
			colorMsgLabel.setText(selectWarning);
			colorTxtBox.setText("");
		}
	}

	private void changeSize() {
		String size_name = sizeTxtBox.getText().toUpperCase();

		if (size_name != null && size_name.length() > 0
				&& size_name.length() < 129) {
			boolean flag = configInventoryFieldsControl.updateSize(size_name,
					selIndxSize);
			if (flag) {
				sizeTxtBox.setText("");
				sizeMsgLabel.setText("");
				sizeMsgLabel.setForeground(Color.BLACK);
				addSizeButton.setEnabled(true);
				selIndxSize = -1;
				sizes_jList.repaint();
			} else {
				// Display Duplicate Value Warning
				sizeMsgLabel.setForeground(Color.RED);
				sizeMsgLabel.setText(updateWarning);
				sizeTxtBox.setText("");
			}
		} else {
			// Display Warning
			sizeMsgLabel.setForeground(Color.RED);
			sizeMsgLabel.setText(sizeSelectWarning);
			sizeTxtBox.setText("");
		}
	}

	private void changeVendor() {
		String vendor_name = vendorTxtBox.getText().toUpperCase();

		if (vendor_name != null && vendor_name.length() > 1
				&& vendor_name.length() < 129) {
			boolean flag = configInventoryFieldsControl.updateVendor(
					vendor_name, selIndxVendor);
			if (flag) {
				vendorTxtBox.setText("");
				vendorMsgLabel.setText("");
				vendorMsgLabel.setForeground(Color.BLACK);
				addVendorButton.setEnabled(true);
				selIndxVendor = -1;
				vendors_jList.repaint();
			} else {
				// Display Duplicate Value Warning
				vendorMsgLabel.setForeground(Color.RED);
				vendorMsgLabel.setText(updateWarning);
				vendorTxtBox.setText("");
			}
		} else {
			// Display Warning
			vendorMsgLabel.setForeground(Color.RED);
			vendorMsgLabel.setText(selectWarning);
			vendorTxtBox.setText("");
		}
	}

	private void deleteItemCatalog() {
		String catlgItem_name = catlgItemTxtBox.getText().toUpperCase();

		if (catlgItem_name != null && catlgItem_name.length() > 0) {
			boolean flag = configInventoryFieldsControl.deleteItemCatalog(
					catlgItem_name, selIndxCatlgItem);
			if (flag) {
				catlgItemTxtBox.setText("");
				catlgItemMsgLabel.setText("");
				catlgItemMsgLabel.setForeground(Color.BLACK);
				addCatlgItemButton.setEnabled(true);
				selIndxCatlgItem = -1;
				categories_jList.repaint();
			} else {
				// Display Duplicate Value Warning
				catlgItemMsgLabel.setForeground(Color.RED);
				catlgItemMsgLabel.setText(deletionWarning);
				catlgItemTxtBox.setText("");
			}
		} else {
			// Display Warning
			catlgItemMsgLabel.setForeground(Color.RED);
			catlgItemMsgLabel.setText(deleteSelectWarning);
			catlgItemTxtBox.setText("");
		}

	}

	private void deleteColor() {
		String color_name = colorTxtBox.getText().toUpperCase();

		if (color_name != null && color_name.length() > 0) {
			boolean flag = configInventoryFieldsControl.deleteColor(color_name,
					selIndxColor);
			if (flag) {
				colorTxtBox.setText("");
				colorMsgLabel.setText("");
				colorMsgLabel.setForeground(Color.BLACK);
				addColorButton.setEnabled(true);
				selIndxColor = -1;
				colors_jList.repaint();
			} else {
				colorMsgLabel.setForeground(Color.RED);
				colorMsgLabel.setText(deletionWarning);
				colorTxtBox.setText("");
			}
		} else {
			// Display Warning
			colorMsgLabel.setForeground(Color.RED);
			colorMsgLabel.setText(deleteSelectWarning);
			colorTxtBox.setText("");
		}

	}

	private void deleteSize() {
		String size_name = sizeTxtBox.getText().toUpperCase();

		if (size_name != null && size_name.length() > 0) {
			boolean flag = configInventoryFieldsControl.deleteSize(size_name,
					selIndxSize);
			if (flag) {
				sizeTxtBox.setText("");
				sizeMsgLabel.setText("");
				sizeMsgLabel.setForeground(Color.BLACK);
				addSizeButton.setEnabled(true);
				selIndxSize = -1;
				sizes_jList.repaint();
			} else {
				sizeMsgLabel.setForeground(Color.RED);
				sizeMsgLabel.setText(deletionWarning);
				sizeTxtBox.setText("");
			}
		} else {
			// Display Warning
			sizeMsgLabel.setForeground(Color.RED);
			sizeMsgLabel.setText(deleteSelectWarning);
			sizeTxtBox.setText("");
		}

	}

	private void deleteItemCategory() {
		String itemCategory_name = itemCategoryTxtBox.getText().toUpperCase();

		if (itemCategory_name != null && itemCategory_name.length() > 0) {
			boolean flag = configInventoryFieldsControl.deleteItemCategory(
					itemCategory_name, selIndxItemCategory);
			if (flag) {
				itemCategoryTxtBox.setText("");
				itemCategoryMsgLabel.setText("");
				itemCategoryMsgLabel.setForeground(Color.BLACK);
				addItemCategoryButton.setEnabled(true);
				selIndxItemCategory = -1;
				categories_jList.repaint();
			} else {
				// Display Duplicate Value Warning
				itemCategoryMsgLabel.setForeground(Color.RED);
				itemCategoryLabel.setText(deletionWarning);
				itemCategoryTxtBox.setText("");
			}
		} else {
			// Display Warning
			itemCategoryMsgLabel.setForeground(Color.RED);
			itemCategoryMsgLabel.setText(deleteSelectWarning);
			itemCategoryTxtBox.setText("");
		}
	}

	private void deleteVendor() {
		String vendor_name = vendorTxtBox.getText().toUpperCase();

		if (vendor_name != null && vendor_name.length() > 0) {
			boolean flag = configInventoryFieldsControl.deleteVendor(
					vendor_name, selIndxVendor);
			if (flag) {
				vendorTxtBox.setText("");
				vendorMsgLabel.setText("");
				vendorMsgLabel.setForeground(Color.BLACK);
				addVendorButton.setEnabled(true);
				selIndxVendor = -1;
				vendors_jList.repaint();
			} else {
				vendorMsgLabel.setForeground(Color.RED);
				vendorMsgLabel.setText(deletionWarning);
				vendorTxtBox.setText("");
			}
		} else {
			// Display Warning
			vendorMsgLabel.setForeground(Color.RED);
			vendorMsgLabel.setText(deleteSelectWarning);
			vendorTxtBox.setText("");
		}

	}

	private void clearItemCatalog() {
		Object selectedCatlgItem = itemCatalog_jList.getSelectedValue();
		catlgItemMsgLabel.setText("");
		selIndxCatlgItem = -1;
		if (selectedCatlgItem != null) {
			catlgItemTxtBox.setText("");
			addCatlgItemButton.setEnabled(true);
			itemCatalog_jList.clearSelection();
		}
	}

	private void clearColor() {
		Object selectedColor = colors_jList.getSelectedValue();
		colorMsgLabel.setText("");
		colorTxtBox.setText("");
		selIndxColor = -1;
		if (selectedColor != null) {
			addColorButton.setEnabled(true);
			colors_jList.clearSelection();
		}
	}

	private void clearSize() {
		Object selectedSize = sizes_jList.getSelectedValue();
		sizeMsgLabel.setText("");
		sizeTxtBox.setText("");
		selIndxSize = -1;
		if (selectedSize != null) {
			addSizeButton.setEnabled(true);
			sizes_jList.clearSelection();
		}
	}

	private void clearItemCategory() {
		Object selectedItemCategory = categories_jList.getSelectedValue();
		itemCategoryMsgLabel.setText("");
		itemCategoryTxtBox.setText("");
		selIndxItemCategory = -1;
		if (selectedItemCategory != null) {
			addItemCategoryButton.setEnabled(true);
			categories_jList.clearSelection();
		}
	}

	private void clearVendor() {
		Object selectedVendor = vendors_jList.getSelectedValue();
		vendorMsgLabel.setText("");
		vendorTxtBox.setText("");
		selIndxVendor = -1;
		if (selectedVendor != null) {
			addVendorButton.setEnabled(true);
			vendors_jList.clearSelection();
		}
	}
}